package com.example.mapper;

import com.example.entity.Admin;
import com.example.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AdminMapper {
    @Select("select * from admin where username = #{username}")
    Admin selectByUsername(String username);

    // 插入学生信息
    @Insert("insert into admin (username,password,name,role)" +
            "values (#{username},#{password},#{name},#{role})")
    void insert(Admin admin);

    // 根据ID更新学生信息
    @Update("update admin set username=#{username},password=#{password},name=#{name} where id=#{id}")
    void updateById(Admin admin);

    // 根据ID删除学生信息
    @Delete("delete from admin where id= #{id}")
    void deleteById(Integer id);

    // 根据条件查询学生信息列表
    @Select("select * from admin where role = 'TEACHER' and username like concat('%',#{username},'%') and name like concat('%',#{name},'%')")
    List<Admin> selectAll(Admin admin);
}